package com.shelpe.services.algorithm.controller;

import java.util.List;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.async.DeferredResult;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import com.shelpe.services.algorithm.client.SinbadClient;

import lombok.Data;

@RequestMapping("/algorithmservice/users/{user_id}")
public interface AutoProductQueueClient {

	@RequestMapping(path = "/autoProductQueues/@start", method = RequestMethod.GET)
	DeferredResult<SinbadClient.AdgroupDto> startAutoDrive(@RequestParam("campaign_id") long campaignID,
			@RequestParam("product_id") long productID);
	
	@RequestMapping(path = "/autoProductQueues/@supplement", method = RequestMethod.GET)
	DeferredResult<AutoDrivingDto> supplementInsight(@RequestParam("campaign_id") long campaignID,
			@RequestParam("product_id") long productID);
	
	@RequestMapping(path = "/autoProductQueues/@word", method = RequestMethod.GET)
	AutoDrivingDto startChooseWords(@RequestParam("campaign_id") long campaignID,
			@RequestParam("product_id") long productID);
	
	@RequestMapping(path = "/autoProductQueues/@adjust", method = RequestMethod.GET)
	AutoDrivingDto adjustAdgroup(@RequestParam("adgroup_id") long adgroupID);
	
	/*
	 * author yechen
	 */
	@RequestMapping(path = "/autoProductQueues",method = RequestMethod.GET)
	List<AutoDriveShows> listByUserID(@PathVariable("user_id") long userID);
	
	@Data
	@JsonInclude(Include.NON_NULL)
	public static class AutoDrivingDto{
		@JsonProperty(value = "success", access = Access.READ_ONLY)
		private boolean success;
		private String message;

		@JsonProperty("campaign_id")
		private long campaignID;
		@JsonProperty("product_id")
		private long productID;
		@JsonProperty("default_price")
		private int defaultPrice;
		@JsonProperty("adgroup_id")
		private long adgroupID;
	}
	
	/*
	 * author yechen
	 */
	@Data
	public static class AutoDriveShows{
		@JsonProperty("user_id")
		private long userID;	    //客户编号
		@JsonProperty("adgroup_id")
		private long adgroupID;		//推广组编号
		@JsonProperty("product_id") 
		private long productID;		 //宝贝编号
		@JsonProperty("campaign_id")
		private long campaignID;  	//推广计划编号
		private int progress;		//进度
		private int status;			//状态
		@JsonProperty("drive_type")
		private int type;			//类型
	}
}